<!--
 * @Description: 
 * @Date: 2024-01-17 08:53:28
 * @LastEditTime: 2024-02-02 09:44:33
-->
<template>
  <el-dialog
    title="满意度评价"
    :visible.sync="dialogVisible"
    class="qc-config-dialog"
    width="800px"
    :append-to-body="true"
  >
    <el-form
      :model="evaluateForm"
      :rules="rules"
      ref="ruleForm"
      label-width="150px"
      class="demo-ruleForm"
    >
      <el-form-item label="对该建议的整体评价" prop="evaluateScore">
        <el-radio-group
          v-model="evaluateForm.evaluateScore"
          placeholder="请输入交办意见"
          clearable
          size="small"
        >
          <el-radio key="1" label="优秀" value="1" />
          <el-radio key="2" label="一般" value="2" />
          <el-radio key="3" label="良好" value="3" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="评价说明" prop="evaluateContent">
        <el-input
          v-model="evaluateForm.evaluateContent"
          placeholder="请输入请假说明"
          type="textarea"
          :rows="4"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm"> 提交评价</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {
  processInfoProId,
  updateProcessInfo,
  userListByRoleId,
} from "@/api/suggest/index";
export default {
  name: "evaluateDialog",
  props: ["value", "type", "proId"],
  data() {
    return {
      dialogVisible: false,
      userList: [],
      evaluateForm: {
        evaluateScore: "",
        evaluateContent: "",
      },
      rules: {
        evaluateScore: [
          { required: true, message: "请选择评价等级", trigger: "change" },
        ],
        evaluateContent: [
          { required: true, message: "请输入评价说明", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    userListByRoleId("7").then((res) => {
      this.userList = res.data.users;
    });
  },
  methods: {
    submitForm() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          updateProcessInfo({
            ...this.evaluateForm,
            status: 6,
            proId: this.proId,
          }).then((res) => {
            this.$message.success("评价成功");
            this.dialogVisible = false;
            this.$parent.getList();
          });
        } else {
          return false;
        }
      });
    },
  },
  watch: {
    value: {
      handler(val) {
        this.dialogVisible = val;
      },
      immediate: true,
    },
    dialogVisible(val) {
      this.$emit("input", val); //关键input
    },
  },
};
</script>

<style lang="scss" scoped></style>
